#include <iostream>
using std::cout;
using std::endl;
class Complex{
public:
    Complex(int real, int image)
    :_real(real)
    ,_image(image)
    {

    }
    Complex(const Complex & rhs)
    :_real(rhs._real)
    ,_image(rhs._image)
    {
        cout << "Complex(const Complex &)" << endl;
    }

    void print(){
        cout << _real << "+" << _image << "i" << endl;
    }

    //++运算符重载函数
    //语法层面针对前置++和后置++做了一个规定
    //后置++需要添加一个int
    //前置++
    //参考内置数据类型的行为表现
    //int a;   ++a    a++
    //先进行加法运算，后返回
    Complex & operator++(){
        ++_real;
        ++_image;
        return *this;
    }

    //后置++：先返回一个临时的，后面本体进行加法运算
    Complex operator++(int){
        Complex temp(*this);
        ++_real;
        ++_image;
        return temp;
    }

private:
    int _real;
    int _image;
};


void test(){
    Complex c1(1, 2), c2(1, 2);

    c1++;
    c1.print();


    ++c2;
    c2.print();
}

int main()
{
    test();
    return 0;
}

